/******************************************************************************
 * Copyright (c) 2020, Realtek Semiconductor Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

#ifndef ROM_SSL_RAM_MAP_H
#define ROM_SSL_RAM_MAP_H

#include "basic_types.h"

struct _rom_ssl_ram_map {
	/* OS interface */
	void *(*ssl_malloc)(unsigned int sz);
	void (*ssl_free)(void *);
	int (*ssl_printf)(const char *, ...);

	//AES HW CRYPTO
	int (*hw_crypto_aes_ecb_init)(const u8* key, const u32 keylen);
	int (*hw_crypto_aes_ecb_decrypt)(
		const u8* message, const u32 msglen,
		const u8* iv, const u32 ivlen,
		u8* pResult);
	int (*hw_crypto_aes_ecb_encrypt)(
		const u8* message, const u32 msglen,
		const u8* iv, const u32 ivlen,
		u8* pResult);
	int (*hw_crypto_aes_cbc_init)(const u8* key, const u32 keylen);
	int (*hw_crypto_aes_cbc_decrypt)(
		const u8* message, const u32 msglen,
		const u8* iv, const u32 ivlen,
		u8* pResult);
	int (*hw_crypto_aes_cbc_encrypt)(
		const u8* message, const u32 msglen,
		const u8* iv, const u32 ivlen,
		u8* pResult);

	//DES HW CRYPTO
	int (*hw_crypto_des_cbc_init)(const u8* key, const u32 keylen);
	int (*hw_crypto_des_cbc_decrypt)(
		const u8* message, const u32 msglen,
		const u8* iv, const u32 ivlen,
		u8* pResult);
	int (*hw_crypto_des_cbc_encrypt)(
		const u8* message, const u32 msglen,
		const u8* iv, const u32 ivlen,
		u8* pResult);
	int (*hw_crypto_3des_cbc_init)(const u8* key, const u32 keylen);
	int (*hw_crypto_3des_cbc_decrypt)(
		const u8* message, const u32 msglen,
		const u8* iv, const u32 ivlen,
		u8* pResult);
	int (*hw_crypto_3des_cbc_encrypt)(
		const u8* message, const u32 msglen,
		const u8* iv, const u32 ivlen,
		u8* pResult);

	/* Variables */
	u32 use_hw_crypto_func;
};

struct _rom_mbedtls_ram_map {
	/* OS interface */
	void *(*ssl_calloc)(unsigned int, unsigned int);
	void (*ssl_free)(void *);
	int (*ssl_printf)(const char *, ...);

	//AES HW CRYPTO
	int (*hw_crypto_aes_ecb_init)(const u8* key, const u32 keylen);
	int (*hw_crypto_aes_ecb_decrypt)(
		const u8* message, const u32 msglen,
		const u8* iv, const u32 ivlen,
		u8* pResult);
	int (*hw_crypto_aes_ecb_encrypt)(
		const u8* message, const u32 msglen,
		const u8* iv, const u32 ivlen,
		u8* pResult);
	int (*hw_crypto_aes_cbc_init)(const u8* key, const u32 keylen);
	int (*hw_crypto_aes_cbc_decrypt)(
		const u8* message, const u32 msglen,
		const u8* iv, const u32 ivlen,
		u8* pResult);
	int (*hw_crypto_aes_cbc_encrypt)(
		const u8* message, const u32 msglen,
		const u8* iv, const u32 ivlen,
		u8* pResult);

	//DES HW CRYPTO
	int (*hw_crypto_des_cbc_init)(const u8* key, const u32 keylen);
	int (*hw_crypto_des_cbc_decrypt)(
		const u8* message, const u32 msglen,
		const u8* iv, const u32 ivlen,
		u8* pResult);
	int (*hw_crypto_des_cbc_encrypt)(
		const u8* message, const u32 msglen,
		const u8* iv, const u32 ivlen,
		u8* pResult);
	int (*hw_crypto_3des_cbc_init)(const u8* key, const u32 keylen);
	int (*hw_crypto_3des_cbc_decrypt)(
		const u8* message, const u32 msglen,
		const u8* iv, const u32 ivlen,
		u8* pResult);
	int (*hw_crypto_3des_cbc_encrypt)(
		const u8* message, const u32 msglen,
		const u8* iv, const u32 ivlen,
		u8* pResult);

	/* Variables */
	u32 use_hw_crypto_func;
};

extern struct _rom_ssl_ram_map rom_ssl_ram_map;
extern struct _rom_mbedtls_ram_map *p_rom_ssl_ram_map; //=&rom_ssl_ram_map init in mbedtls_platform_set_calloc_free
#endif	/* ROM_SSL_RAM_MAP_H */
